package cate.game.role.mail.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMail;
import cate.game.role.mail.Mail;
import easy.java.dev.note.NoteField;

import java.util.List;

@ClientMsg(title = "邮件操作 の 请求")
public class MailOperReq implements MsgInput {
    @NoteField(value = "需要被设为已读的邮件的_idHex们", detail = "可以为NULL")
    public List<String> readList;

    @NoteField(value = "需要被领取奖励的邮件的_idHex们", detail = "可以为NULL")
    public List<String> gotList;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<List<Mail>> r = cc.getRole().getMail().oper(readList,gotList);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r);
        } else {
            MailOperResp resp = new MailOperResp();
            resp.updates = r.data;
            cc.sendNow(resp);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBMail.MAIL_OPERATION_REQ;
    }
}
